package com.lagou.rpc.provider;

import com.lagou.rpc.provider.server.RpcServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.List;

@SpringBootApplication
public class ServerBootstrapApplication implements CommandLineRunner {


    @Autowired
    RpcServer rpcServer;

    public static void main(String[] args) {
        SpringApplication.run(ServerBootstrapApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        List<String> ipList = List.of("127.0.0.1", "127.0.0.2", "127.0.0.3");

        for (String ip : ipList) {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    rpcServer.startServer(ip, 8899);
                }
            }).start();
        }
    }
}
